<?php

include "class/food.php";

/**
 * 勤劳程度：A,B,C
 * 人：A,B,C
 * 事：apple,meat,rice
 */
class Person
{
    protected $name;

    //构造函数
    public function __construct($name)
    {
        $this->name = $name;
//        echo __METHOD__ . "<br>";
    }

    public function __set($name, $value)
    {
        echo "set $name, $value <br>";
    }

    public function __get($name)
    {
        echo "get $name <br>";
    }

    public function __isset($name)
    {
        echo 'isset ' . $name . '<br>';
    }

    public function eat(Food2 $food)
    {
        $food->growup();
    }
}

abstract class Food2
{
    public $name = 'food2';

    abstract public function growup();
}

class FoodSon extends Food2
{
    public function growup()
    {
        echo "$this->name growup<br>";
    }
}


$a = new Person('A');
//$a->name = 'daily';
//$a->age = 10;
//var_dump($a);

//isset($a->xxxx);

//unset($a->name);

$f2 = new FoodSon('foodson');

$a->eat($f2);


